$tfamfile = $ARGV[0];
chomp($tfamfile);
$sampleqc = $ARGV[1];
chomp($sampleqc);
$outsampleqc = $ARGV[2];
chomp($outsampleqc);
open BUFF,"$tfamfile" or die "no file found $tfamfile\n";
open(WRBUFF,">$outsampleqc");
print WRBUFF "SampleID\tFLAG\tMISSING_GENO_CLEAN\tNUM_GENO_CLEAN\tQC_SAMPLE_FLAG\tQC_SAMPLE_IND\tQC_SEX_IND\tPLINK_SEX_IMP_ESTIMATE\n";
$n1 = 0;
while(<BUFF>)
{	
	chomp($_);
	@array = split(" ",$_);
	$hash{$array[1]} = 1;
	$n1++;
}
$n2 = 0;
open BUFF,"$sampleqc" or die "no file found $sampleqc\n";
while(<BUFF>)
{
        chomp($_);
	@array = ();
        @array = split("\t",$_);
        if(exists($hash{$array[0]}))
	{
		print WRBUFF $_."\n";
		$n2++;
	}
}
if($n1 != $n2)
{
	die "samples not equal in tfam and sample QC\n";
}

